use aqua::{client::prelude::*, http::{HttpMethod, HttpRequest}};
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct Student {
    pub id: String,
    pub name: String,
    pub gender: String,
    pub score: i32,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = Client::connect("127.0.0.1:7878").await?;
    
    let request = HttpRequest::builder()
        .method(HttpMethod::Post)
        .path("/api/add_student")?
        .json(&Student {
            id: "3030303".into(),
            name: "SB".into(),
            gender: "Unkown".into(),
            score: 59
        })?
        .build()?;

    let response = client.send(request).await?;
    println!("{:?}", response);

    Ok(())
}